Miniscript is a language for composing Bitcoin Script in a structured way, facilitating analysis, composition, and generic signing. It's a simplified, composable subset of the Bitcoin Script language. Developed to overcome limitations in writing complex spending conditions directly in Bitcoin Script, it enables formal verification and offers a more human-friendly interface.
Have reviewed templates that leverage Miniscript to assure there are not unintended ways of executing a valid spend beyond the intended Miniscript policy.
Have standardized usages of Miniscript to streamline software and hardware wallet integrations.
Have uniform on-chain usage of Miniscript templates for better privacy.
A 3-of-3 multisig quorum that transitions to a 2-of-3 after 90 days2
Input3:
thresh(3, pk(key1), pk(key2), pk(key_3), older(12960))
Output4:
thresh(3, pk(key1), s:pk(key2), s:pk(key_3), sln:older(12960))
A fragment note5.
s:X SWAP [X]
n:X [X] 0NOTEQUAL
l:X = or_i(0,X) IF 0 ELSE [X] ENDIF
A footnote6.
Resulting Bitcoin Script structure7.
<key_1> OP_CHECKSIG OP_SWAP <key_2> OP_CHECKSIG OP_ADD OP_SWAP <key_3>
OP_CHECKSIG OP_ADD OP_SWAP OP_IF
0
OP_ELSE
<a032> OP_CHECKSEQUENCEVERIFY OP_0NOTEQUAL
OP_ENDIF
OP_ADD 3 OP_EQUALSpending cost analysis8:
Script: 122 WU
Input: 166.250000 WU
Total: 288.250000 WU
TxID:
testnet:13a204ec065f76878ee1f59f79b3eb2cea2b3fda4d8938e6cfa6a8394d090769
github.com/sipa/miniscript/tree/master
Use at your own risk. ↩
144 blocks per day x 90 days = 12960 blocks additonal info here: miniscript.h ↩
nSequence ≥ n > 0 (add link)
older(NUM) ~> <NUM> CHECKSEQUENCEVERIFY
additonal info here: miniscript.h ↩
nLockTime ≥ n > 0 (add link)
after(NUM) ~> <NUM> CHECKLOCKTIMEVERIFY
additonal info here: miniscript.h ↩
Given a script, be able to predict the cost of spending an output. ↩
"f" Forced: dissatisfying this expression always requires a signature (predicting whether all dissatisfactions will be HASSIG). ↩
"e" Expressive: this requires a unique unconditional dissatisfaction to exist, and forces all conditional dissatisfactions (if any) to require a signature. ↩
"s" Signed: satisfying this expression always requires a signature (predicting whether all satisfactions will be HASSIG). ↩